﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eSYSU.Model;

public partial class WeiboOauth : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request["oauth_verifier"] != null && Request["e_token"] != null)
            {
                oAuthSina oauth = new oAuthSina();
                string[] token = Request["e_token"].ToString().Split(new char[] { '-' });
                oauth.token = token[0];
                oauth.tokenSecret = token[1];
                oauth.Verifier = Request["oauth_verifier"].ToString();
                oauth.AccessTokenGet();

                WeiboBinding wb = new WeiboBinding();
                wb.userId = 1;
                wb.name = "";
                wb.type = "sina";
                wb.weiboUserId = oauth.userId;
                wb.screenName = oauth.screenName;
                wb.accessToken = oauth.token;
                wb.accessSecret = oauth.tokenSecret;
                eSYSU.Business.WeiboService.WeiboBindingUpdate(wb);

                Response.Redirect("/WeiboOauth.aspx?flag=ok");
            }
            if (Request["flag"] != null)
            {
                Response.Write("绑定成功");
            }
        }
    }
}